import { shareAppMessageSet } from "../../../utils/config"
import { dataCollection } from "../../../utils/dataCollection"
// pages/class/introduction/introduction.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    title: '',
    introduce: {
      tag: '',
      type: 'video',
      url: '',
      content: '',
      poster: ''
    },
    themeCode:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    //从本地获取当前选择的城市编码
    this.setData({
      themeCode:wx.getStorageSync('themeCode')
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    const introduce = wx.getStorageSync('introduce')
    wx.setNavigationBarTitle({ title: introduce.tag })
    this.setData({
      introduce
    })

    if (introduce.type === 'video') {
      this.createSelectorQuery().select('.video').context(res => {
        if (res) {
          console.log(res.context)
          // setTimeout(() => {
          //   res.context.play()
          // }, 100)
        }
      }).exec()
    }
  },
  onHide(){
    dataCollection.setPageMapData('leave')
  },
  onUnload(){
    dataCollection.setPageMapData('leave')
  },
  onShow(){
    dataCollection.setPageMapData('enter','班级详情-介绍')
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    return {...shareAppMessageSet()}
  }
})